class TextCommand extends EscCommand {
  int type = 1;
  int? textSize; //字体大小
  bool? bold;
  String content;
  int? lineSpace;
  double? scaleWidth;
  double? scaleHeight;
  PrintItemAlign? itemAlign;

  TextCommand(
    this.content, {
    this.textSize,
    this.bold,
    this.lineSpace,
    this.itemAlign,
    this.scaleWidth,
    this.scaleHeight,
  });

  Map<String, dynamic> toJson() {
    Map<String, dynamic> data = <String, dynamic>{};
    data["type"] = 1;
    data["bold"] = bold;
    data["content"] = content;
    data["textSize"] = textSize;
    data["lineSpace"] = lineSpace;
    data["scaleWidth"] = scaleWidth;
    data["scaleHeight"] = scaleHeight;
    if (itemAlign != null) {
      data["itemAlign"] = itemAlign?.value;
    }
    return data;
  }
}

class MultipleTextCommand extends EscCommand {
  List<double> scales;

  List<TextCommand> texts;

  int? lineSpace;

  MultipleTextCommand(this.scales, this.texts, {this.lineSpace});

  @override
  Map<String, dynamic> toJson() {
    Map<String, dynamic> data = <String, dynamic>{};
    data["type"] = 2;
    data["scales"] = scales;
    data["texts"] = texts.map((e) => e.toJson()).toList();
    data["lineSpace"] = lineSpace;
    return data;
  }
}

class EscCommand {
  Map<String, dynamic> toJson() => {};
}

enum PrintItemAlign {
  LEFT(0),
  CENTER(1),
  RIGHT(2);

  const PrintItemAlign(this.value);

  final int value;
}
